package com.lab.dao.impl;

import java.util.Map;

import org.apache.ibatis.session.SqlSession;

import com.lab.dao.PassWordDao;
import com.lab.util.MySqlSessionFactory;

public class PassWordDaoImpl implements PassWordDao{

	
	//新增学生账号密码
	@Override
	public int addStuPwd(Map map) {
		SqlSession session=null;
		int i=0;
		try {
			session=MySqlSessionFactory.getSqlSession();
			i=session.insert("PassWordXml.addStuPwd",map);
			session.commit();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			if(session!=null){
				session.close();
			}
		}		
		return i;
	}

	
	//更改密码
	@Override
	public int updateStuPwd(Map map) {
		int i=0;
		SqlSession session=null;
		try {
			session=MySqlSessionFactory.getSqlSession();		
			i = session.update("PassWordXml.updateStuPwd",map);
			session.commit();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			if(session!=null){
				session.close();
			}
		}
		return i;
	}

	//删除账号
	@Override
	public int deleteStuPwd(int stId) {
		int i = 0;
		SqlSession session=null;
		try {
			session=MySqlSessionFactory.getSqlSession();
			i=session.delete("PassWordXml.deleteStuPwd", stId);
			session.commit();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			if(session!=null){
				session.close();
			}
		}
		return i;
	}


}
